package com.example.esp32;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.esp32.R;

import java.util.ArrayList;
import java.util.List;

public class adapterwifi extends BaseAdapter {
    private Context mContext;
    private List<getValue> mList = new ArrayList<getValue>();

    class ViewHolder {
        TextView ssid,jmfs,xhqd;
        ImageView xh,xxxx;
    }
    public adapterwifi(Context context, List<getValue> list) {
        mContext = context;
        mList = list;
    }
    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        adapterwifi.ViewHolder viewHolder = null;
        //初始化卡片样式
        if (view == null) {
            viewHolder = new adapterwifi.ViewHolder();
            view = LayoutInflater.from(mContext).inflate(R.layout.wifilist, null);
            viewHolder.ssid = view.findViewById(R.id.ssid);
            viewHolder.jmfs = view.findViewById(R.id.jmfs);
            viewHolder.xhqd = view.findViewById(R.id.xhqd);
            viewHolder.xxxx = view.findViewById(R.id.xxxx);

            viewHolder.xh = view.findViewById(R.id.xh);



            view.setTag(viewHolder);
        } else {
            viewHolder = (adapterwifi.ViewHolder) view.getTag();
        }
        viewHolder.xh.setImageResource(mList.get(i).getTupian());

        viewHolder.ssid.setText(mList.get(i).getas());
        viewHolder.jmfs.setText(mList.get(i).getdyzt());
        viewHolder.xhqd.setText(mList.get(i).getsbmc());

//        viewHolder.bianji.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                mOnItemUpdateListener.onUpdateClick(i);
//            }
//        });
        viewHolder.xxxx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                xxxx.onxxxxClick(i);
            }
        });

        return view;
    }
    public interface xxxx {
        void onxxxxClick(int i);

    }

    private xxxx xxxx;

    public void setOnItemxxxxClickListener(xxxx mOnItemDeleteListener) {
        this.xxxx = mOnItemDeleteListener;
    }

    public void clear() {

        if (mList != null) {
            mList.clear();
        } else {
            mList.clear();
        }

    }
    }

